-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Velocity Command Ignored Checking #321
Conversation
mbf_abstract_nav/include/mbf_abstract_nav/abstract_controller_execution.h
Outdated
Show resolved
Hide resolved
mbf_abstract_nav/include/mbf_abstract_nav/abstract_controller_execution.h
Outdated
Show resolved
Hide resolved
mbf_abstract_nav/include/mbf_abstract_nav/abstract_controller_execution.h
Outdated
Show resolved
Hide resolved
mbf_abstract_nav/include/mbf_abstract_nav/abstract_controller_execution.h
Outdated
Show resolved
Hide resolved
mbf_abstract_nav/include/mbf_abstract_nav/abstract_controller_execution.h
Outdated
Show resolved
Hide resolved
* @param cmd_velocity the latest cmd_vel being published to the robot | ||
* @return true if cmd_vel is being ignored by the robot longer than tolerance time, false otherwise | ||
*/ | ||
bool checkVelocityIgnore(const geometry_msgs::Twist& cmd_velocity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: a bit more precise; and cmd_vel
is the conventional name we use
bool checkVelocityIgnore(const geometry_msgs::Twist& cmd_velocity); | |
bool checkCmdVelIgnored(const geometry_msgs::Twist& cmd_vel); |
// check if robot ignores velocity command | ||
if (robot_ignore_vel_enabled && checkVelocityIgnore(cmd_vel_stamped.twist)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// check if robot ignores velocity command | |
if (robot_ignore_vel_enabled && checkVelocityIgnore(cmd_vel_stamped.twist)) | |
// check if robot is ignoring velocity commands | |
if (robot_ignore_vel_enabled && checkVelocityIgnore(cmd_vel_stamped.twist)) |
|
||
// check if the velocity ignore check is enabled or not | ||
bool robot_ignore_vel_enabled = (robot_ignore_check_tolerance_ > 0.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: don't need ()
const double cmd_linear = std::hypot(cmd_velocity.linear.x, cmd_velocity.linear.y); | ||
const double cmd_angular = std::abs(cmd_velocity.angular.z); | ||
|
||
bool cmd_is_not_zero = (cmd_linear > 0.01 || cmd_angular > 0.01); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: this is forcing u to make a double negation on the if below (avoid contorted logic whenever possible)
// check if robot ignores the cmd_vel | ||
double ignored_duration = (ros::Time::now() - first_ignored_time_).toSec(); | ||
ROS_WARN_THROTTLE(1, | ||
"Robot ignores velocity command for %.2f seconds.\n The cmd_vel being ignored is: (x=%.2f, " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Robot ignores velocity command for %.2f seconds.\n The cmd_vel being ignored is: (x=%.2f, " | |
"Robot ignores velocity command for %.2f seconds (commanded velocity: x=%.2f, " |
if (ignored_duration > robot_ignore_check_tolerance_) | ||
{ | ||
// the robot is ignoring the velocity command more the threshold time | ||
ROS_ERROR("Robot is disabled and the time it ignored velocity command exceeded the tolerance time: %.2f seconds", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F: we don't know why is ignoring vel commands, so better not to make statements like "robot is disabled" can be off, can be blocked against a wall,,,, we don't know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much better, but still needs some work
general comment: I think here "is ignoring" makes more sense than "ignores" (but u live in USA, so i trust your criteria)
const double cmd_linear = std::hypot(cmd_vel.linear.x, cmd_vel.linear.y); | ||
const double cmd_angular = std::abs(cmd_vel.angular.z); | ||
|
||
const bool cmd_is_zero = (cmd_linear < 0.01 && cmd_angular < 0.01); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: maybe use 1e-3 here too?
S: I think u can remove the brackets (not 100% sure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested without the brackets and it was working fine. So I removed it.
// the robot is ignoring the velocity command more the threshold time | ||
ROS_ERROR("Robot is ignoring velocity command for more than the tolerance time: %.2f seconds", | ||
cmd_vel_ignored_tolerance_); | ||
return true; // return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return true; // return true | |
return true; |
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line?
@@ -185,6 +186,63 @@ void AbstractControllerExecution::setVelocityCmd(const geometry_msgs::TwistStamp | |||
// TODO so there should be no loss of information in the feedback stream | |||
} | |||
|
|||
bool AbstractControllerExecution::checkCmdVelIgnored(const geometry_msgs::Twist& cmd_vel) | |||
{ | |||
// check if the velocity ignore check is enabled or not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// check if the velocity ignore check is enabled or not | |
// check if the velocity ignored check is enabled or not |
// set to zero if not already zero | ||
if (!first_ignored_time_.is_zero()) | ||
{ | ||
first_ignored_time_ = ros::Time(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F: not needed if we are not checking vel ignored
// velocity is not being ignored | ||
if (!robot_stopped || cmd_is_zero) | ||
{ | ||
// set to zero if not already zero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F: this comment says the same as the code. Write comments only to clarify non-obvious steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same goes for the next 2 comments
first_ignored_time_ = ros::Time::now(); | ||
} | ||
|
||
// check if robot ignores the cmd_vel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F: comment is wrong. you already know that the robot is ignoring
@@ -310,6 +310,14 @@ void ControllerAction::runImpl(GoalHandle &goal_handle, AbstractControllerExecut | |||
goal_handle.setAborted(result, result.message); | |||
break; | |||
|
|||
case AbstractControllerExecution::ROBOT_DISABLED: | |||
ROS_FATAL_STREAM_NAMED(name_, "Robot ignored velocity commands for more than tolerance time"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F: You will have almost the same error log twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
almost there...
@@ -234,6 +242,9 @@ namespace mbf_abstract_nav | |||
//! The time the controller responded with a success output (output < 10). | |||
ros::Time last_valid_cmd_time_; | |||
|
|||
//! The first time when the robot is ignoring velocity command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! The first time when the robot is ignoring velocity command | |
//! The time when the robot started ignoring velocity commands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good!
I added some extra suggestion
} | ||
|
||
const double ignored_duration = (ros::Time::now() - first_ignored_time_).toSec(); | ||
ROS_WARN_THROTTLE(1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: maybe this should go after the error (line 234) so you don't show both WARN and ERROR together
Problem Summary:
When the robot is disabled/not moving due to hardware/firmware issues or obstacles, and the planner keeps feeding non-zero velocity commands to the robot, we need to inform the users know something is wrong with the robot that it is ignoring cmd_vel.
Feature:
This is an implementation of the velocity ignored checking and error displaying feature. When the robot is not moving for N seconds(set by a parameter) while the planner keeps publishing non-zero commands, it will output an error and fatal message on the ROS console and sends a error code. Velocity command ignored check is performed every time we got an new velocity command from the planner.
If user would like to enable the feature, change the
cmd_vel_ignored_tolerance
parameter to be higher than zero. Otherwise, set a value below zero.